import 'package:dali_ng_pera/global/dnp_global_manager.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'dnp_splash_controller.dart';

class DnpSplashWidget extends StatefulWidget {
  const DnpSplashWidget({super.key});

  @override
  State<DnpSplashWidget> createState() => _DnpSplashWidgetState();
}

class _DnpSplashWidgetState extends State<DnpSplashWidget> {

  final controller = Get.put(DnpSplashController());

  @override
  void initState() {
    super.initState();
    DnpGlobalManager().setBuildContext(context);
  }

  @override
  void dispose() {
    super.dispose();
    Get.delete<DnpSplashController>();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor:Color(0xFF0193FE),
      body: Stack(
        children: [
          Image.asset(
            'assets/images/ic_splash_bg.webp',
            fit: BoxFit.fill,
            height: double.infinity,
            width:double.infinity,
          ),
          Positioned(
            left:51,
            right: 51,
            bottom: 99,
            child: GestureDetector(
              onTap: () async{
                controller.initializeData();
              },
              child: Container(
                height: 54,
                alignment: Alignment.center,
                decoration: BoxDecoration(
                  image: DecorationImage(
                    image: AssetImage('assets/images/ic_splash_button.webp'),
                    fit: BoxFit.fill,
                  ),
                ),
                child: Text(
                  'Try again',
                  style: TextStyle(
                    fontSize: 16,
                    fontWeight: FontWeight.w700,
                    color: Color(0xFF252630),
                  ),
                ),
              ),
            )
          )
        ],
      ),
    );
  }
}

